export default {
  namespaced: true,
  state: {
    // 保存所有角色可以访问所有导航
    menus: [
      {
        icon: 'el-icon-discover',
        label: '仪表盘',
        path: '/dashBoard',
        roles: ['a', 'b', 'c']
      },
      {
        label: '商品',
        icon: 'el-icon-shopping-/bag-1',
        roles: ['a', 'b', 'c'],
        children: [
          {
            label: '商品分类管理',
            path: '/cateLists'
          },
          {
            label: '商品管理',
            path: '/itemLists'
          }
        ]
      },
      {
        icon: 'el-icon-setting',
        label: '设置',
        roles: ['b', 'c'],
        path: '/setting'
      }
    ]
  },
  mutations: {
    FILTER_MENUS (state, role) {
      // 根据用户角色判断 哪些导航可以访问哪些不可以
      state.menus = state.menus.filter(menu => menu.roles.includes(role))
    }
  }
}
